// main
import {context} from "./server/ServerContext";
import {LoggerFactory} from "./logs/Logger";
import home from "./api/Home";
import fileRoute from "./api/FileService";

const log = LoggerFactory.getLogger('index')
// 添加请求执行前的逻辑
context.addPlugin(server => {
    server.use((req, res, next) => {
        log.info(`IP => ${req.ip} , source => ${req.url}`)
        next()
    })
})

// 添加路由
context.addPlugin(server => {
    server.use(home)
        .use(fileRoute)
})

context.start().then(r => {
    log.info(`服务启动完成,点击下面地址访问   http://${context.getEnv("host")}:${context.getEnv("port")}/`)
})
